home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / MiniGames / BTW / BreakTheWallMG.as next >
Text File  |  2013-04-24  |  4KB  |  122 lines

  1. class MiniGames.BTW.BreakTheWallMG extends MiniGames.BaseMiniGame
  2. {
  3.    static var sSTATE_NORMAL = "Normal";
  4.    static var sSTATE_WHACKY = "Whacky";
  5.    static var nMAX_TIME = 15;
  6.    static var nSECOND_VALUE = 100;
  7.    function BreakTheWallMG(_mcRef)
  8.    {
  9.       super(_mcRef);
  10.       this.showInstructions();
  11.    }
  12.    function initMiniGame()
  13.    {
  14.       this.aBalls = new Array();
  15.       this.oSpongeBob = new MiniGames.BTW.BTWSpongeBob(this.mcRef.mcState.mcBob,this);
  16.       this.oWallPart1 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart1,this);
  17.       this.oWallPart2 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart2,this);
  18.       this.oWallPart3 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart3,this);
  19.       this.oWallPart4 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart4,this);
  20.       this.oWallPart5 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart5,this);
  21.       this.oWallPart6 = new MiniGames.BTW.BTWWallPart(this.mcRef.mcState.mcPart6,this);
  22.    }
  23.    function destroyMiniGame()
  24.    {
  25.       super.destroyMiniGame();
  26.       this.oWallPart1.cleanUp();
  27.       this.oWallPart2.cleanUp();
  28.       this.oWallPart3.cleanUp();
  29.       this.oWallPart4.cleanUp();
  30.       this.oWallPart5.cleanUp();
  31.       this.oWallPart6.cleanUp();
  32.       this.oSpongeBob.cleanUp();
  33.       for(var i in this.aBalls)
  34.       {
  35.          this.aBalls[i].cleanUp();
  36.       }
  37.    }
  38.    function calculateScore()
  39.    {
  40.       this.addScoreFromTimeLeft(MiniGames.BTW.BreakTheWallMG.nMAX_TIME,MiniGames.BTW.BreakTheWallMG.nSECOND_VALUE);
  41.    }
  42.    function validateEndMiniGame()
  43.    {
  44.       if(this.oWallPart1.isDestroyed() && (this.oWallPart2.isDestroyed() && (this.oWallPart3.isDestroyed() && (this.oWallPart4.isDestroyed() && (this.oWallPart5.isDestroyed() && this.oWallPart6.isDestroyed())))))
  45.       {
  46.          this.setVictory();
  47.       }
  48.    }
  49.    function setState(_sState)
  50.    {
  51.       super.setState(_sState);
  52.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  53.       {
  54.          if(Main.getRef().isCheatClothesActivated())
  55.          {
  56.             this.mcRef.mcState.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_WHACKY);
  57.          }
  58.          else
  59.          {
  60.             this.mcRef.mcState.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_NORMAL);
  61.          }
  62.       }
  63.       else if(Main.getRef().isCheatClothesActivated())
  64.       {
  65.          this.mcRef.mcBack.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_WHACKY);
  66.       }
  67.       else
  68.       {
  69.          this.mcRef.mcBack.gotoAndStop(MiniGames.BTW.BreakTheWallMG.sSTATE_NORMAL);
  70.       }
  71.    }
  72.    function doUnPause()
  73.    {
  74.       super.doUnPause();
  75.       this.mcRef.stop();
  76.       this.mcRef.mcBack.stop();
  77.       if(this.sState == MiniGames.BaseMiniGame.sSTATE_MINIGAME || this.sState == MiniGames.BaseMiniGame.sSTATE_VICTORY)
  78.       {
  79.          this.mcRef.mcState.stop();
  80.       }
  81.    }
  82.    function clickOnWall(_oSrc)
  83.    {
  84.       this.oSpongeBob.throwABall(_oSrc);
  85.    }
  86.    function createBall(_oAimWall, _nX, _nY)
  87.    {
  88.       this.aBalls.push(new MiniGames.BTW.BTWBall(this.mcRef.mcState,_oAimWall,_nX,_nY));
  89.    }
  90.    function MiniGame()
  91.    {
  92.       super.MiniGame();
  93.       var _loc3_ = this.aBalls.length - 1;
  94.       while(_loc3_ >= 0)
  95.       {
  96.          if(this.aBalls[_loc3_].isExploding())
  97.          {
  98.             this.aBalls[_loc3_].Target.damage();
  99.          }
  100.          else if(this.aBalls[_loc3_].isDestroyed())
  101.          {
  102.             this.aBalls[_loc3_].cleanUp();
  103.             delete this.aBalls[_loc3_];
  104.             this.aBalls.splice(_loc3_,1);
  105.          }
  106.          _loc3_ = _loc3_ - 1;
  107.       }
  108.       if(this.oWallPart1.isDestroyed() && (this.oWallPart3.isDestroyed() && this.oWallPart5.isDestroyed()))
  109.       {
  110.          this.mcRef.mcState.mcShadowLeft._visible = false;
  111.       }
  112.       if(this.oWallPart2.isDestroyed() && (this.oWallPart4.isDestroyed() && this.oWallPart6.isDestroyed()))
  113.       {
  114.          this.mcRef.mcState.mcShadowRight._visible = false;
  115.       }
  116.    }
  117.    function Victory()
  118.    {
  119.       this.bOver = true;
  120.    }
  121. }
  122.